package com.woniu.project.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.woniu.project.core.domain.ProductEntityIdentify;
import com.woniu.project.core.dto.ResultDto;
import com.woniu.project.dto.identifydto.IdentifyDto;
import com.woniu.project.params.identifyparams.IdentifyConditionParams;
import com.woniu.project.params.identifyparams.IdentifyParams;
import com.woniu.project.service.IProductEntityIdentifyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.Date;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author WHF
 * @since 2020-10-13
 */
@RestController
@RequestMapping("/identify")
@Slf4j
@Api(tags = "identify控制层")
public class ProductEntityIdentifyController {

    @Autowired
    private IProductEntityIdentifyService productEntityIdentifyService;

    /**
     * 新增一条鉴定记录
     * @param identifyParams 鉴定记录对象
     * @return
     */
    @ApiOperation(value = "新增鉴定记录",notes = "productEntityId，identifyManId，productEntityIdentifyStatus必填")
    @PostMapping("insertIdentity")
    public ResultDto insertIdentity(@Valid @RequestBody IdentifyParams identifyParams){
        log.info("新增一条鉴定记录时传入的对象为：{}",identifyParams);

        productEntityIdentifyService.insertIdentity(identifyParams);
        return ResultDto.success(200,"新增成功",null);
    }

    /**
     * 分页查询单个商品下的所有历史鉴定记录
     * @param identifyConditionParams 查询条件参数对象
     * @return
     */
    @ApiOperation(value = "新增鉴定记录",notes = "productEntityId必填")
    @GetMapping("selectIdentityList")
    public ResultDto selectIdentityList(IdentifyConditionParams identifyConditionParams){
        log.info("查询鉴定记录时传入的id为：{}",identifyConditionParams);
        IPage<IdentifyDto> identifyDtoIPage = productEntityIdentifyService.selectIdentityList(identifyConditionParams);
        return ResultDto.success(identifyDtoIPage);
    }


}

